package com.example.smartgreenhouse.WebSocketServer;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@Service
public class WarnWebSocketServer {
    private final SimpMessagingTemplate messagingTemplate;

    @Autowired
    public WarnWebSocketServer(SimpMessagingTemplate messagingTemplate) {
        this.messagingTemplate = messagingTemplate;
    }

    public void warn(String topic, JSONObject json){
        messagingTemplate.convertAndSend("/topic/"+topic, json);
    }
}
